home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / libfpvm / WIN32 / Pvmftasks.c < prev    next >
C/C++ Source or Header  |  1997-07-22  |  2KB  |  75 lines

  1.  
  2. /* $Id: Pvmftasks.c,v 1.1 1997/06/27 16:34:40 pvmsrc Exp $ */
  3.  
  4. #ifdef WIN32
  5. #include "..\..\include\pvm3.h"
  6. #include "..\..\src\pvmwin.h"
  7. #else 
  8. #include "pvm3.h"
  9. #endif
  10.  
  11. #include "pvm_consts.h"
  12. #include "../../src/bfunc.h"
  13.  
  14. void /*__stdcall*/ __fortran
  15. PVMFTASKS
  16.    (where,
  17.       ntaskp,
  18.       tidp,
  19.       ptidp,
  20.       hostp,
  21.       flagp,
  22.       a_out_ptr,a_out_len,
  23.       infop)
  24.  
  25.    int  *where, *ntaskp, *tidp, *ptidp, *hostp, *flagp, *infop;
  26.    char * a_out_ptr; int a_out_len;
  27. {
  28.    static struct pvmtaskinfo *tip = 0;
  29.    static int ntask = 0;
  30.    static int next = 0;
  31.  
  32.    int cc;
  33.    struct pvmtaskinfo *tip2;
  34.  
  35. #ifndef WIN32
  36.    char *malloc();
  37. #endif
  38. /* if user sets ntaskp to -1 then pvmftasks() will be reset */
  39.  
  40.     if (tip && (*ntaskp == -1)) {
  41.         free((char*)tip);
  42.         tip = 0;
  43.     }
  44.  
  45.    if (!tip) {
  46.       if ((cc = pvm_tasks(*where, &ntask, &tip2)) < 0) {
  47.          *infop = cc;
  48.          return;
  49.       }
  50.       tip = (struct pvmtaskinfo*)malloc(ntask * sizeof(struct pvmtaskinfo));
  51.       BCOPY((char*)tip2, (char*)tip, ntask * sizeof(struct pvmtaskinfo));
  52.       next = 0;
  53.    }
  54.  
  55.    if (next < ntask) {
  56.       *ntaskp = ntask;
  57.       *tidp = tip[next].ti_tid;
  58.       *ptidp = tip[next].ti_ptid;
  59.       *hostp = tip[next].ti_host;
  60.       *flagp = tip[next].ti_flag;
  61.       ctofstr(a_out_ptr, a_out_len, tip[next].ti_a_out);
  62.       *infop = 1;
  63.       next++;
  64.    }
  65.  
  66. /* can not return ti_pid without changing interface */
  67. /* users needing this will have to use C            */
  68.  
  69.    if (next == ntask) {
  70.       free((char*)tip);
  71.       tip = 0;
  72.    }
  73. }
  74.  
  75.